<template>
	<view class="index">
			<music-head title="歌曲" :isShow='false'></music-head>
			<view class="index_search">
				<view class="search_content" @tap="handleToSearch()">
					<view class="iconfont icon-sousuo search_icon"></view>
					<view class="search_text"><text>搜索歌曲</text></view>
				</view>
			</view>
			<view class="container">
				<scroll-view scroll-y="true">
					<view v-if="loading">
					<m-for-skeleton
						:avatarSize="200"
						:row="3"
						:loading="loading"
						isarc="square"
						v-for="(item,key) in 4"
						:key='key'
						:titleStyle='titleStyle'>
					</m-for-skeleton>
					</view>
					<view v-else="loading" class="hot_list_content" v-for="(item) in toplists" :key="item.id" @tap="handleToList(item.id)">
						<view class="list_left">
							<image class="list_img" :src="item.coverImgUrl"></image>
							<view class="list_text"><text>{{ item.name }}</text></view>
						</view>
						<view class="list_right">
							<view class="list_title" v-for="(item,index) in item.tracks" :key="index"><text>{{index}}.  {{item.first}} - {{item.second}}</text></view>
						</view>
					</view>
				</scroll-view>
			</view>
	</view>
</template>

<script>
	import { toplist } from '../../common/api.js'
	export default {
		data() {
			return {
				title: 'Hello',
				toplists: [],
				loading: true,
				size: '50px',
				titleStyle: {
					
				}
			}
		},
		onLoad() {
			this.loading = true
			toplist().then((res)=>{
				this.toplists = res
				setTimeout(()=>{
				    this.loading = false
				}, 200);
			})
		},
		methods: {
			handleToList(listId){
				uni.navigateTo({
					url: '../list/list?listId=' + listId,
					success(){
						console.log(listId)
					}
				})
			},
			handleToSearch (){
				uni.navigateTo({
					url: '../search/search',
					success(){
					}
				})
			}
		}
	}
</script>
	
<style lang="scss">
		// 搜索输入框
		.index_search{
			width: 100%;
			display: flex;
			align-items:center;
			justify-content: center;
			height: 105rpx;
			.search_content{
				display: flex;
				align-items: center;
				height: 70rpx;
				width: 100%;
				margin: 0rpx 32rpx;
				border-radius: 20px;
				background-color: rgb(247, 247, 247);
				.search_icon{
					margin: 0 20rpx;
					font-size: 35rpx;
					color: rgb(181, 181, 181);
				}
				.search_text{
					font-size: 32rpx;
					color: rgb(138, 138, 138);
				}
			}
		}
		.container{
			width: 100%;
			height: calc(100vh - 75px);
			overflow: hidden;
			
			scroll-view{
					height: 100%;
			}
			
			.hot_list_content{
				width: 100%;
				height: 212rpx;
				margin: 20px 32rpx;
				display: flex;
				align-items: center;
				
				.list_left{
					width: 212rpx;
					height: 212rpx;
					flex-shrink: 0;
					background-color: black;
					border-radius: 5px;
					position: relative;
					
					.list_img{
						width: 100%;
						height: 100%;
						overflow: hidden;
					}
					.list_text{
						position: absolute;
						left: 12rpx;
						bottom: 5rpx;
						font-size: 23rpx;
						color: white;
					}
				}
				.list_right{
					width: 460rpx;
					height: 212rpx;
					margin-left: 16rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-evenly;
					
					.list_title{
						width: 100%;
						white-space: nowrap;
						text-overflow: ellipsis;
						overflow: hidden;
						text{
							color: rgb(68, 68, 68);
							font-size: 27rpx;
						}
					}
				}
			}
		}
</style>
